﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace EHR.Ctrls.QueryDesign
{
    public partial class GridDesignColumn : UserControl
    {
        private ColInfo _colInfo;
        public GridDesignColumn(ColInfo colInfo)
        {
            InitializeComponent();

            LayoutRoot.DataContext = this;

            SetColInfo(colInfo);
        }

        public bool IsVisible
        {
            get { return (bool)chkIsVisible.IsChecked; }
        }

        public string Title
        {
            get { return (string)GetValue(TitleProperty); }
            set { SetValue(TitleProperty, value); }
        }

        // Using a DependencyProperty as the backing store for Title.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty TitleProperty =
            DependencyProperty.Register("Title", typeof(string), typeof(GridDesignColumn), new PropertyMetadata(""));


        public bool MouseEnter(double x)
        {
            if (x > 0 && x < Width && this.Visibility == Visibility.Visible)
            {
                leftLend.Visibility = Visibility.Collapsed;
                rightLend.Visibility = Visibility.Visible;

                return true;
            }
            else
            {
                leftLend.Visibility = Visibility.Collapsed;
                rightLend.Visibility = Visibility.Collapsed;
                return false;
            }
        }

        public void MouseLeft()
        {
            leftLend.Visibility = Visibility.Collapsed;
            rightLend.Visibility = Visibility.Collapsed;
        }

        public void SetColInfo(ColInfo col)
        {
            _colInfo = col;

            Title = col.DisplayName;
            Width = col.Width;
            chkIsVisible.IsChecked = col.IsVisible;
        }

        public ColInfo GetColInfo()
        {
            ColInfo col = _colInfo;
            col.DisplayName = Title;
            col.Width = (int)Width;
            col.IsVisible = (bool)chkIsVisible.IsChecked;
            return col;
        }

        public void UpdateColInfo()
        {
        }
    }
}
